package customer.zspt.cn.customer.utils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
 * Created by Administrator on 2018/6/11 0011.
 */
public class StreamTools {
    public static String InputToString(InputStream is) {
        ByteArrayOutputStream bt = new ByteArrayOutputStream();
        byte[] bs = new byte[1024];
        int temp = -1;
        try {
            while ((temp = is.read(bs)) != -1) {
                bt.write(bs, 0, temp);
            }
            byte[] rsbs = bt.toByteArray();
            String text = new String(rsbs);
            return text;
        } catch (IOException e) {
            e.printStackTrace();
        }
        finally {
            try
            {
                bt.close();
                is.close();
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
        }
        return null;

    }
}
